import store from '../base/store'
import Sprite from '../base/sprite'

/**
 * 计分器精灵
 */
export class ScoreSprite extends Sprite {
  /** 分数 */
  private scoreNumber = 0

  constructor() {
    super()
  }

  /**
   * 分数计算
   * @returns 精灵实例
   */
  public calc(): ScoreSprite {
    this.scoreNumber++
    return this
  }

  /**
   * 绘制函数
   * @returns 无
   */
  public override draw(): void {
    this.ctx.font = '18px Arial' // 字体
    this.ctx.fillStyle = '#333' // 字色
    this.ctx.fillText(
      `【OOP实现】得分:${this.scoreNumber}`,
      10,
      store.canvas.width / 10,
      1000
    )
  }
}
